package com.guo.book1.factory;

import java.util.Objects;

public class CourseFactory {
    public ICourse create(Class<? extends ICourse> clazz) {
        try{
            if(Objects.nonNull(clazz)) {
//                return clazz.newInstance();
                return clazz.getDeclaredConstructor().newInstance();
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
